package com.ruoyi.project.jiaqin.recruitindustry.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.jiaqin.recruitindustry.domain.RecruitIndustry;
import com.ruoyi.project.jiaqin.recruitindustry.service.IRecruitIndustryService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 招聘行业Controller
 * 
 * @author admin
 * @date 2021-01-06
 */
@Controller
@RequestMapping("/jiaqin/recruitindustry")
public class RecruitIndustryController extends BaseController
{
    private String prefix = "jiaqin/recruitindustry";

    @Autowired
    private IRecruitIndustryService recruitIndustryService;

    @RequiresPermissions("jiaqin:recruitindustry:view")
    @GetMapping()
    public String recruitindustry()
    {
        return prefix + "/recruitindustry";
    }

    /**
     * 查询招聘行业列表
     */
    @RequiresPermissions("jiaqin:recruitindustry:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(RecruitIndustry recruitIndustry)
    {
        startPage();
        List<RecruitIndustry> list = recruitIndustryService.selectRecruitIndustryList(recruitIndustry);
        return getDataTable(list);
    }

    /**
     * 导出招聘行业列表
     */
    @RequiresPermissions("jiaqin:recruitindustry:export")
    @Log(title = "招聘行业", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(RecruitIndustry recruitIndustry)
    {
        List<RecruitIndustry> list = recruitIndustryService.selectRecruitIndustryList(recruitIndustry);
        ExcelUtil<RecruitIndustry> util = new ExcelUtil<RecruitIndustry>(RecruitIndustry.class);
        return util.exportExcel(list, "recruitindustry");
    }

    /**
     * 新增招聘行业
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存招聘行业
     */
    @RequiresPermissions("jiaqin:recruitindustry:add")
    @Log(title = "招聘行业", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(RecruitIndustry recruitIndustry)
    {
        return toAjax(recruitIndustryService.insertRecruitIndustry(recruitIndustry));
    }

    /**
     * 修改招聘行业
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        RecruitIndustry recruitIndustry = recruitIndustryService.selectRecruitIndustryById(id);
        mmap.put("recruitIndustry", recruitIndustry);
        return prefix + "/edit";
    }

    /**
     * 修改保存招聘行业
     */
    @RequiresPermissions("jiaqin:recruitindustry:edit")
    @Log(title = "招聘行业", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(RecruitIndustry recruitIndustry)
    {
        return toAjax(recruitIndustryService.updateRecruitIndustry(recruitIndustry));
    }

    /**
     * 删除招聘行业
     */
    @RequiresPermissions("jiaqin:recruitindustry:remove")
    @Log(title = "招聘行业", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(recruitIndustryService.deleteRecruitIndustryByIds(ids));
    }
}
